home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / comm / ftp4w24b.zip / ftp4w.h < prev    next >
C/C++ Source or Header  |  1995-11-21  |  12KB  |  255 lines

  1.  
  2. /* *************************************************************** */
  3. /*                                                                 */
  4. /*                                                                 */
  5. /*                                                                 */
  6. /*    FTP4W.DLL  (Version 2.4)                                     */
  7. /*                                                                 */
  8. /*                                                                 */
  9. /*                                   By Ph. Jounin (SNCF 71-26-12) */
  10. /*                                        Internet ark@ifh.sncf.fr */
  11. /*                                            Copyright SNCF 94-95 */
  12. /* *************************************************************** */
  13.  
  14.  
  15. #ifndef FTP4W_API
  16.  
  17. #include <winsock.h>
  18.  
  19. #ifdef __cplusplus  
  20. extern "C" {            /* Assume C declarations for C++ */   
  21. #endif  /* __cplusplus */   
  22.  
  23. #ifdef DEBUG
  24. #  define  FTP_DATABUFFER  256                 /* slown down the transfer */
  25. #else
  26. #  define  FTP_DATABUFFER  4096 /* a good value for X25/Ethernet/Token Ring */
  27. #endif
  28.  
  29.  
  30.  
  31. /* ----------------------------------------------------------- */
  32.  
  33. /* ASCII or binary tranfser */
  34. #define   TYPE_A        'A'
  35. #define   TYPE_I        'I'
  36. #define   TYPE_DEFAULT   0
  37.  
  38. /* ----------------------------------------------------------- */
  39. /*              Return codes of FTP functions                  */
  40. /* ----------------------------------------------------------- */
  41. /* success */
  42. #define  FTPERR_OK                    0 /* succesful function                */
  43. /* OK but waits for further parameters */
  44. #define  FTPERR_ENTERPASSWORD         1 /* userid need a password            */
  45. #define  FTPERR_ENTERNEEDED           2 /* user/pass OK but account required */
  46. #define  FTPERR_ACCOUNTNEEDED         2 /* user/pass OK but account required */
  47. #define  FTPERR_RESTARTOK             3 /* Restart command successful        */
  48. #define  FTPERR_CANCELBYUSER         -1 /* Transfer aborted by user FtpAbort */
  49. /* user's or programmer's Errors  */
  50. #define  FTPERR_INVALIDPARAMETER   1000 /* Error in parameters               */
  51. #define  FTPERR_SESSIONUSED        1001 /* User has already a FTP session    */
  52. #define  FTPERR_NOTINITIALIZED     1002 /* FtpInit has not been call         */
  53. #define  FTPERR_NOTCONNECTED       1003 /* User is not connected to a server */
  54. #define  FTPERR_CANTOPENFILE       1004 /* can not open specified file       */
  55. #define  FTPERR_CANTOPENLOCALFILE  FTPERR_CANTOPENFILE
  56. #define  FTPERR_CANTWRITE          1005 /* can't write into file (disk full?)*/
  57. #define  FTPERR_NOACTIVESESSION    1006 /* FtpRelease without FtpInit        */
  58. #define  FTPERR_STILLCONNECTED     1007 /* FtpRelease without any Close      */
  59. #define  FTPERR_SERVERCANTEXECUTE  1008 /* file action not taken             */
  60. #define  FTPERR_LOGINREFUSED       1009 /* Server rejects usrid/passwd       */
  61. #define  FTPERR_NOREMOTEFILE       1010 /* server can not open file          */
  62. #define  FTPERR_TRANSFERREFUSED    1011 /* Host refused the transfer         */
  63. #define  FTPERR_WINSOCKNOTUSABLE   1012 /* A winsock.DLL ver 1.1 is required */
  64. #define  FTPERR_CANTCLOSE          1013 /* Close failed (cmd is in progress) */
  65. #define  FTPERR_FILELOCKED         1014 /* temporary error during FtpDelete  */
  66. /* TCP errors */
  67. #define  FTPERR_UNKNOWNHOST        2001 /* can not resolve host adress       */
  68. #define  FTPERR_NOREPLY            2002 /* host does not send an answer      */
  69. #define  FTPERR_CANTCONNECT        2003 /* Error during connection           */
  70. #define  FTPERR_CONNECTREJECTED    2004 /* host has no FTP server            */
  71. #define  FTPERR_SENDREFUSED        2005 /* can't send data (network down)    */
  72. #define  FTPERR_DATACONNECTION     2006 /* connection on data-port failed    */
  73. #define  FTPERR_TIMEOUT            2007 /* timeout occured                   */
  74. /* FTP server errors */
  75. #define  FTPERR_UNEXPECTEDANSWER   3001  /* answer was not expected          */
  76. #define  FTPERR_CANNOTCHANGETYPE   3002  /* host rejects the TYPE command    */
  77. #define  FTPERR_CMDNOTIMPLEMENTED  3003  /* host recognize but can't exec cmd*/
  78. #define  FTPERR_PWDBADFMT          3004  /* PWD cmd OK, but answer has no "  */
  79. #define  FTPERR_PASVCMDNOTIMPL     3005  /* Server don't support passive mode*/
  80. /* Resource errors */
  81. #define  FTPERR_CANTCREATEWINDOW   5002  /* Insufficent free resources       */
  82. #define  FTPERR_INSMEMORY          5003  /* Insuffisent Heap memory          */
  83. #define  FTPERR_CANTCREATESOCKET   5004  /* no more socket                   */
  84. #define  FTPERR_CANTBINDSOCKET     5005  /* bind is not succesful            */
  85. #define  FTPERR_SYSTUNKNOWN        5006  /* host system not in the list      */
  86.  
  87. /* ----------------------------------------------------------- */
  88.  
  89. struct S_FtpData
  90. {
  91.    SOCKET   ctrl_socket;    /* control stream       init INVALID_SOCKET */
  92.    SOCKET   data_socket;    /* data stream          init INVALID_SOCKET */
  93.    char     cType;          /* type (ASCII/binary)  init TYPE_A         */
  94.    BOOL     bVerbose;       /* verbose mode         init FALSE          */ 
  95.    BOOL     bPassif;        /* VRAI -> mode passif                      */ 
  96.    unsigned short nPort;    /* connexion Port       init FTP_DEFPORT    */
  97.    unsigned nTimeOut;       /* TimeOut in seconds   init FTP_DEFTIMEOUT */
  98.    HFILE    hLogFile;       /* Log file                                 */ 
  99.    char     szInBuf [1024]; /* incoming Buffer                          */
  100.    struct sockaddr_in saSockAddr;   /* not used anymore */
  101.    struct sockaddr_in saAcceptAddr; /* not used anymore */
  102. }; /* struct S_FtpData */
  103.  
  104.  
  105. struct S_FileTrf 
  106. {
  107.    HFILE    hf;         /* handle of the file which is being transfered */
  108.    unsigned nCount;     /* number of writes/reads made on a file        */
  109.    unsigned nAsyncAlone;/* pause each N frame in Async mode  (Def 40)   */
  110.    unsigned nAsyncMulti;/* Idem but more than one FTP sssion (Def 10)   */
  111.    unsigned nDelay;     /* time of the pause in milliseconds            */
  112.    BOOL     bAborted;   /* data transfer has been canceled              */
  113.    char     szBuf[FTP_DATABUFFER]; /* Data buffer                       */
  114.    BOOL     bNotify;    /* application receives a msg each data packet  */
  115.    BOOL     bAsyncMode; /* synchronous or asynchronous Mode             */
  116.    LONG     lPos;       /* Bytes transfered                             */
  117.    LONG     lTotal;     /* bytes to be transfered                       */
  118. }; /* struct S_FileTrf */
  119.  
  120. struct S_Msg
  121. {
  122.    HWND          hParentWnd;        /* window which the msg is to be passed   */
  123.    UINT          nCompletedMessage; /* msg to be sent at end of the function  */
  124. };  /* struct S_Msg */
  125.  
  126.  
  127. struct S_Verbose
  128. {
  129.    HWND          hVerboseWnd;  /* window which the message is to be passed    */
  130.    UINT          nVerboseMsg;  /* msg to be sent each time a line is received */
  131. };
  132.  
  133. /* global structure */
  134. struct S_ProcData
  135. {  
  136.    /* task data */
  137.    HTASK      hTask;              /* Task Id                              */
  138.    HWND       hFtpWnd;            /* Handle of the internal window        */
  139.    HWND       hParentWnd;         /* handle given to the FtpInit function */
  140.    HINSTANCE  hInstance;          /* Task Instance                        */
  141.    BOOL       bRelease;           /* FtpRelease has been called           */
  142.  
  143.    /* Mesasge information */
  144.    struct S_Msg      Msg;      
  145.    struct S_Verbose  VMsg;      
  146.                                                                
  147.    /* File information */
  148.    struct S_FileTrf  File;  
  149.  
  150.    /* Ftp information */
  151.    struct S_FtpData   ftp;
  152.    
  153.    /* Linked list */
  154.    struct S_ProcData far *Next;
  155.    struct S_ProcData far *Prev;
  156. }; /* struct S_ProcData */
  157.  
  158. typedef struct S_ProcData far * LPProcData;
  159. typedef struct S_FtpData far *  LPFtpData;
  160.  
  161.  
  162.  
  163. /* **************************************************************** */
  164. /*                                                                  */
  165. /*                    P R O T O T Y P E S                           */
  166. /*                                                                  */
  167. /* **************************************************************** */
  168.  
  169. /* Utilities functions */
  170. LPProcData PASCAL FAR  FtpDataPtr (void);
  171. int PASCAL FAR WEP (int nType);
  172. int PASCAL FAR Ftp4wVer (LPSTR szVerStr, int nStrSize);
  173.  
  174. /* change default parameters */
  175. int  PASCAL FAR FtpSetVerboseMode (BOOL bVerboseMode, HWND hVerboseWnd, UINT wMsg);
  176. long PASCAL FAR FtpBytesTransferred (void);
  177. long PASCAL FAR FtpBytesToBeTransferred(void);
  178. void PASCAL FAR FtpSetDefaultTimeOut (int nTo_in_sec);
  179. void PASCAL FAR FtpSetDefaultPort(int nDefPort);
  180. void PASCAL FAR FtpSetAsynchronousMode(void);
  181. void PASCAL FAR FtpSetSynchronousMode(void);
  182. BOOL PASCAL FAR FtpIsAsynchronousMode(void);   
  183. void PASCAL FAR FtpSetNewDelay(int x); 
  184. void PASCAL FAR FtpSetNewSlices(int x,int y) ;
  185. void PASCAL FAR FtpSetPassiveMode (BOOL bPassive);
  186. void PASCAL FAR FtpLogTo (HFILE hLogFile);
  187. /* mispelled functions - only for backwards compatibilty */
  188. long PASCAL FAR FtpBytesTransfered (void);
  189. long PASCAL FAR FtpBytesToBeTransfered(void);
  190.  
  191. /* Init functions */
  192. int PASCAL FAR FtpRelease (void);
  193. int PASCAL FAR FtpInit (HWND hParentWnd);
  194. int PASCAL FAR FtpFlush (void);
  195.  
  196. /* Connection */
  197. int PASCAL FAR FtpLogin (LPSTR szHost, LPSTR szUser, LPSTR szPasswd,
  198.                          HWND hParentWnd, UINT wMsg);
  199. int PASCAL FAR FtpOpenConnection (LPSTR szHost);
  200. int PASCAL FAR FtpCloseConnection (void);
  201. int PASCAL FAR FtpLocalClose (void);
  202.  
  203. /* authentification */
  204. int PASCAL FAR  FtpSendUserName (LPSTR szUserName);
  205. int PASCAL FAR  FtpSendPasswd (LPSTR szPasswd);
  206. int PASCAL FAR  FtpSendAccount (LPSTR szAccount);
  207.  
  208. /* commands */
  209. int PASCAL FAR FtpHelp   (LPSTR szArg, LPSTR szBuf, UINT uBufSize);
  210. int PASCAL FAR FtpDeleteFile (LPSTR szRemoteFile);
  211. int PASCAL FAR FtpRenameFile (LPSTR szFrom, LPSTR szTo);
  212. int PASCAL FAR FtpQuote  (LPSTR szCmd, LPSTR szReplyBuf, UINT uBufSize);
  213. int PASCAL FAR FtpSyst   (LPSTR FAR *szSystemStr);
  214. int PASCAL FAR FtpSetType(char cType);
  215. int PASCAL FAR FtpCWD    (LPSTR szPath);
  216. int PASCAL FAR FtpCDUP   (void);
  217. int PASCAL FAR FtpPWD    (LPSTR szBuf, UINT uBufSize);
  218. int PASCAL FAR FtpMKD    (LPSTR szPath, LPSTR szFullDir, UINT uBufSize);
  219. int PASCAL FAR FtpRMD    (LPSTR szPath);
  220.  
  221. /* file transfer */
  222. int PASCAL FAR FtpAbort (void);
  223. int PASCAL FAR FtpSendFile (LPSTR szLocal, LPSTR szRemote, char cType, 
  224.                             BOOL bNotify, HWND hParentWnd, UINT wMsg);
  225. int PASCAL FAR FtpAppendToRemoteFile (LPSTR szLocal, LPSTR szRemote,char cType,
  226.                             BOOL bNotify, HWND hParentWnd, UINT wMsg);
  227. int PASCAL FAR FtpRecvFile (LPSTR szRemote, LPSTR szLocal, char cType, 
  228.                             BOOL bNotify, HWND hParentWnd, UINT wMsg);
  229. int PASCAL FAR FtpAppendToLocalFile (LPSTR szLocal, LPSTR szRemote,char cType,
  230.                             BOOL bNotify, HWND hParentWnd, UINT wMsg);
  231. DWORD PASCAL FAR FtpGetFileSize (void);
  232.  
  233. int PASCAL FAR FtpRestart (long lByteCount);
  234. int PASCAL FAR FtpRestartSendFile (HFILE hLocal, LPSTR szRemote, char cType, 
  235.                             BOOL bNotify, long lByteCount,
  236.                             HWND hParentWnd, UINT wMsg);
  237. int PASCAL FAR FtpRestartRecvFile (LPSTR szRemote, HFILE hLocal, char cType, 
  238.                             BOOL bNotify, long lByteCount,
  239.                             HWND hParentWnd, UINT wMsg);
  240.  
  241.  
  242. /* Directory */
  243. int PASCAL FAR FtpDir (LPSTR szDef, LPSTR szLocalFile,
  244.                        BOOL  bLongDir, HWND  hParentWnd, UINT wMsg);
  245.  
  246. /* _______________________________________________________________ */
  247.  
  248. #ifdef __cplusplus     
  249. }  /* End of extern "C" */   
  250. #endif /* ifdef __cplusplus */  
  251.  
  252. #define FTP4W_API loaded
  253. #endif /* ifndef FTP4W_API */
  254.  
  255.